﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using DotNETX.GIS.Web.StaticTMS.Classes;

namespace DotNETX.GIS.Web
{
    public partial class TMSList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Services services = LoadServices();
            this.Repeater1.DataSource = services;
            this.Repeater1.DataBind();
        }

        protected string GetBaseUrl()
        {
            string path = this.Request.Url.AbsoluteUri;
            return path.Substring(0, path.Length - "Default.aspx".Length);
        }

        protected Services LoadServices()
        {
            string path = GetBaseUrl() + "tms.ashx?act=list";
            string xmlServices = WebRequest.Open(path);
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(Services));
            return xs.Deserialize(new StringReader(xmlServices)) as Services;
        }
    }
}